package com.bdqn.t330.ch12.entity;

import java.io.Serializable;
import java.util.List;

public class Page<T> implements Serializable {
    //总记录数
    private int totalRecord = 0;
    //总页数
    private int totalPage = 1;
    //当前是第几页
    private int currentPage = 1;
    //每页显示多少条记录
    private int pageSize = 5;

    private List<T> list;

    public int getTotalRecord() {
        return totalRecord;
    }

    public void setTotalRecord(int totalRecord) {
        this.totalRecord = totalRecord;
        if (this.totalRecord % pageSize == 0) {
            totalPage = this.totalRecord / pageSize;
        } else {
            totalPage = (this.totalRecord / pageSize) + 1;
        }
    }

    public int getTotalPage() {
        return totalPage;
    }

    public void setTotalPage(int totalPage) {
        this.totalPage = totalPage;
    }

    public int getCurrentPage() {
        return currentPage;
    }

    public void setCurrentPage(int currentPage) {
        this.currentPage = currentPage;
    }

    public int getPageSize() {
        return pageSize;
    }

    public void setPageSize(int pageSize) {
        this.pageSize = pageSize;
    }

    public List<T> getList() {
        return list;
    }

    public void setList(List<T> list) {
        this.list = list;
    }

    @Override
    public String toString() {
        return "Page{" +
                "totalRecord=" + totalRecord +
                ", totalPage=" + totalPage +
                ", currentPage=" + currentPage +
                ", pageSize=" + pageSize +
                ", list=" + list +
                '}';
    }
}
